<?php
declare(strict_types=1);

namespace TpAmis\Provider;

use DomainException;
use \think\Paginator as tpPaginator;

/**
 * 分页类
 * 重新调整分页输出格式
 */
class Paginator extends tpPaginator
{
    public function render()
    {

    }
 /**
     * 转换为数组
     * @return array
     */
    public function toArray(): array
    {
        try {
            $total = $this->total();
        } catch (DomainException $e) {
            $total = null;
        }

        return [
            'count'        => $total,//总数
            'perPage'     => $this->listRows(),//每页数量
            'Page' => $this->currentPage(),//当前页
            'last_page'    => $this->lastPage,//最后一页
            'items'         => $this->items->toArray(),//数据
        ];
    }
}
